﻿using System;
using System.Data;
using System.Data.Common;
using System.Text;
using IToursDataService;
using IToursDataService.Models;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace ToursDataService
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“EntertainmenRestaurantOrderCtrl”。
    public class EntertainmenRestaurantOrderCtrl : IEntertainmenRestaurantOrderCtrl
    {

        public DataTable GetEntertainmenRestaurantOrderData(string tourgroupId)
        {

            Database db = DatabaseFactory.CreateDatabase();

            DbCommand dbCommand;
            //string sql = string.Format(@"SELECT r.*,p.City FROM fee_EntertainmentOrder r,bas_Provider p WHERE r.ProviderID=p.ProviderID AND TourgroupID='{0}'", tourgroupId);
            string sql = string.Format(@"SELECT r.*,p.City FROM fee_EntertainmentOrder r,bas_Provider p WHERE r.ProviderID=p.ProviderID AND TourgroupID='{0}'  AND p.ProviderType='{1}'", tourgroupId, ProviderTypeEnum.餐厅);
            dbCommand = db.GetSqlStringCommand(sql);

            DataSet ds = db.ExecuteDataSet(dbCommand);
            if (ds.Tables.Count > 0)
                return ds.Tables[0];
            else
                return null;
        }
    }
}
